package com.bnu.attachment.Controller;

import com.bnu.attachment.Service.AttachmentService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author ：Zzy1211
 * @date ：Created in 2019/11/6 21:19
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping(value = "/attachment")
public class AttachmentController {

	@Resource
    private AttachmentService attachmentService;

/*
    功能：显示附件路径
    接口格式：http://localhost:8080/attachment/show?a_pid=
*/
    @ResponseBody
    @PostMapping(value = "/show")
    public Object Show(HttpServletRequest request){
    	return attachmentService.Show(request);
    }


/*
    功能：上传文件
    接口格式：http://localhost:8080/attachment/upload/
*/
    @ResponseBody
    @PostMapping(value = "/upload")
    public Object Upload(HttpServletRequest request) throws ServletException {
    	return attachmentService.Upload(request);
    }

   /*
    功能：下载文件
    接口格式：http://localhost:8080/attachment/download?attach=显示文件路径
*/
    @PostMapping(value = "/download")
    public void Upload(HttpServletRequest request,HttpServletResponse response){
    	attachmentService.Download(request,response);
    }


}